package net.office.service.impl;

import net.office.bean.BaseAttr;
import net.office.bean.BaseAttrExample;
import net.office.mapper.BaseAttrMapper;
import net.office.service.BaseAttrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BaseAttrServiceImpl implements BaseAttrService {

    @Autowired
    private BaseAttrMapper baseAttrMapper;

    @Override
    public int updateByPrimaryKey(BaseAttr baseAttr) {

        return baseAttrMapper.updateByPrimaryKey(baseAttr);
    }

    @Override
    public BaseAttr findByAttrCode(String attrCode) {
        BaseAttrExample example = new BaseAttrExample();
        example.createCriteria().andAttrCodeEqualTo(attrCode);

        List<BaseAttr> baseAttrList = baseAttrMapper.selectByExample(example);

        if (baseAttrList.size() == 1){
            return baseAttrList.get(0);
        }

        return null;
    }

    @Override
    public BaseAttr findByPrimaryKey(Integer attrId) {
        return baseAttrMapper.selectByPrimaryKey(attrId);
    }
}
